package sv.love.boot.redis.pubsub;

import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisSentinelPool;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

public class PubSubDemo {

    public static void main( String[] args )
    {

        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(10);
        config.setMaxWaitMillis(1000);

        String masterName = "mymaster";
        Set<String> sentinelSet = new HashSet<>();
       sentinelSet.add("192.168.12.70:26379");
        // 连接redis服务端
        JedisSentinelPool jedisPool = new JedisSentinelPool(masterName,sentinelSet,config );

        System.out.println(String.format("redis pool is starting, redis ip %s, redis port %d", "192.168.12.70", 26379));

        SubThread subThread = new SubThread(jedisPool);  //订阅者
        subThread.start();

        Publisher publisher = new Publisher(jedisPool);    //发布者
        publisher.start();
        new ArrayList<String>();
    }
}